<?php


namespace App\Http\Requests\Admin\Business;


use App\Facade\AppContext;
use App\Http\Requests\BaseFormRequest;
use App\Models\Business\AgentWallet;
use Illuminate\Validation\Rule;

class AgentWalletSaveFormRequest extends BaseFormRequest
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $id = $this->get('id', 0);
        $coin = $this->get('coin', '');
        $roles = [
            'coin' => [
                'required'
            ],
            'wallet' => [
                'required',
                Rule::unique(AgentWallet::class, 'wallet')->where('coin',$coin)->where('agent_id',AppContext::userId())->where('deleted_at',0)->ignore($id)
            ]
        ];
        return $roles;
    }
}